#include "unit--.h"
#include "../WMIConnection.h"
#include "../WMIConnectionMng.h"
#include <comdef.h>
#include <Wbemidl.h>
#include"../WRegistry.h"
#include"../RegistryManager.h"
#include "../WConstants.h"

# pragma comment(lib, "wbemuuid.lib")

using namespace unit_minus;

testSuite(POCSuite);

testCase(RegMngTest1, POCSuite)
{
    cout << "---------- Start RegistryManager Test ----------" << endl;
    WMIConnection con;
    WHResult* whres;
	WMIConnectionMng* mng = new WMIConnectionMng();
	whres = mng->initCOMSecurityConfiguration();
    delete whres;

	whres = mng->createConnection(PC_LOCAL_USER, PC_LOCAL_PASSWORD, PC_NAMESPACE_REG, con);
    delete whres;

	RegistryManager man(&con);

 	WRegistry* rclass=new WRegistry();

	assertTrue(rclass->getName() == CONST_HKEY_LOCAL);

	whres = man.getRegistrys(R_LOCAL_MACHINE,EMPTY_SUBKEY,&rclass);
    delete whres;

	assertTrue(rclass->getRegistryList().size()>0);

	for(int i = 0;i < rclass->getRegistryList().size(); i++)
	{
		if(rclass->getRegistryList().at(i)->getName() == HW)
		{
			assertTrue(rclass->getRegistryList().at(i)->getName() == HW);
		}
	}


	vector<WRegistry> reg;
	man.getStandardRegistryHives(reg);
	
	cout << "******** Predefined Registry Hives********* " << endl;
	for(vector<WRegistry>::iterator i = reg.begin(); i != reg.end(); i++)
		(*i).print();

	assertTrue(4 == reg.size())

	con.close();
    cout << "---------- End RegistryManager Test ----------" << endl << endl;
    system("PAUSE");

}

